<?php

use common\logic\OrderStatus;
use common\logic\SupplyStatus;
use common\logic\PaymentStatus;
use common\logic\AccountStatus;
use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model backend\models\Order */

$this->title = $model->id;
$this->params['breadcrumbs'][] = ['label' => 'Orders', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="order-view">
	<p>
        <?php if ($model->order_status == OrderStatus::PAID && $model->supply_status == SupplyStatus::UNSET && $model->payment_status == PaymentStatus::PAID && $model->account_status == AccountStatus::UNSET) {
            echo Html::a('确认订单', [
                'platform-confirm',
                'id' => $model->id
            ], [
                'class' => 'btn btn-primary',
                'data' => [
                    'confirm' => '确定订单并向booker下单吗？',
                    'method' => 'post',
                ],
            ]);
		} elseif($model->order_status == OrderStatus::PAID && $model->supply_status == SupplyStatus::ORDER && $model->payment_status == PaymentStatus::PAID && $model->account_status == AccountStatus::UNSET) {
            echo Html::a('供应商确认', [
                'supply-confirm',
                'id' => $model->id
            ], [
                'class' => 'btn btn-primary',
                'data' => [
                    'confirm' => '确认已收到booker邮件, 更新订单为供应商为确认状态吗？',
                    'method' => 'post',
                ],
            ]);
        } elseif($model->order_status == OrderStatus::CONFIRMED && $model->supply_status == SupplyStatus::CONFIRMED && $model->payment_status == PaymentStatus::PAID && $model->account_status == AccountStatus::TO_REMIT) {
            echo Html::a('更新为向供应商汇款', [
                'supply-confirm',
                'id' => $model->id
            ], [
                'class' => 'btn btn-primary',
                'data' => [
                    'confirm' => '准备向供应商汇款, 更新订单为供应商汇款状态吗？',
                    'method' => 'post',
                ],
            ]);
        } ?>

        <?php echo Html::a('取消订单并退款', [
            'refund',
            'id' => $model->id
        ], [
            'class' => 'btn btn-primary',
            'data' => [
                'confirm' => '确认退款吗？',
                'method' => 'post',
            ],
        ]); ?>

        <?=Html::a('更新', ['update', 'id' => $model->id], ['class' => 'btn btn-info ']) ?>
        <?= Html::a('删除', ['delete', 'id' => $model->id], [
            'class' => 'btn btn-danger',
            'data' => [
                'confirm' => '确定要删除这个订单？',
                'method' => 'post',
            ],
        ]) ?>
    </p>

    <?= DetailView::widget([
        'model' => $model,
        'attributes' => [
            'id',
            'uid',
            'order_id',
            'ctime',
            'utime',
            'order_status',
            'supply_status',
            'payment_status',
            'account_status',
            'deleted',
            'trip_id',
			'cabin_id',
            'one_self',
            'occupancy_id',
            //'room_ids',
            'contact',
            'ext:ntext',
            'payment:ntext',
            'email:email',
            'phone',
            'fund_amount',
            'use_protect',
            'message',
        ],
    ]) ?>

</div>
